package com.gjj;

import com.gjj.common.PropertiesUtils;
import com.gjj.controller.IndexController;
import com.gjj.model.MyUpload;
import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;
import com.jfinal.upload.UploadFile;

public class MyConfig extends JFinalConfig {
    @Override
    public void configConstant(Constants me) {
        me.setDevMode(true);
        me.setBaseUploadPath(PropertiesUtils.getProperty("file_dir"));
    }

    @Override
    public void configRoute(Routes me) {
        me.setBaseViewPath("/view");
        me.add("/",IndexController.class,"/");
    }

    @Override
    public void configEngine(Engine me) {

    }

    @Override
    public void configPlugin(Plugins me) {
        String jdbcUrl =PropertiesUtils.getProperty("jdbcUrl");
        String userName = PropertiesUtils.getProperty("userName");
        String password = PropertiesUtils.getProperty("password");
//        String driverClass = PropertiesUtils.getProperty("driverClass");

//        DruidPlugin dp = new DruidPlugin(jdbcUrl, userName, password,driverClass);
//        me.add(dp);

        C3p0Plugin c3p0Plugin = new C3p0Plugin(jdbcUrl, userName, password);
        me.add(c3p0Plugin);

        ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
        arp.addMapping("uploadFile", MyUpload.class);
        me.add(arp);
    }

    @Override
    public void configInterceptor(Interceptors me) {

    }

    @Override
    public void configHandler(Handlers me) {

    }
}
